package com.lcj.mis.controller;

import com.lcj.common.util.Result;
import com.lcj.mis.controller.form.DeleteRuleForm;
import com.lcj.mis.controller.form.InsertRuleForm;
import com.lcj.mis.controller.form.SearchRuleForm;
import com.lcj.mis.controller.form.UpdateRuleForm;
import com.lcj.mis.service.RuleService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController
@RequestMapping("/rule")
@Tag(name = "RuleManageController", description = "MIS系统规则管理接口")
public class RuleManageController {

    @Resource
    private RuleService ruleService;

    @PostMapping("/searchRule")
    public Result SearchRule(@RequestBody @Valid SearchRuleForm form) {
        Result result = ruleService.searchRule(form);
        return result;
    }

    @PostMapping("/insertRule")
    public Result insertRule(@RequestBody @Valid InsertRuleForm form) {
        Result result = ruleService.insertRule(form);
        return result;
    }

    @PostMapping("/updateRule")
    public Result updateRule(@RequestBody @Valid UpdateRuleForm form) {
        Result result = ruleService.updateRule(form);
        return result;
    }

    @PostMapping("/deleteRule")
    public Result deleteRule(@RequestBody @Valid DeleteRuleForm form) {
        Result result = ruleService.deleteRule(form);
        return result;
    }
}
